const getValue = (list, value) => {
  const result = list.find(item => `${item.value}` == `${value}`);
  return result || { name: "", type: "default" };
};
// 未归还状态
export const noReturnType = val => {
  const list = [
    { name: "正常借出", value: 1, type: "success" },
    { name: "异常归还", value: 2, type: "warning" },
    { name: "超期未归还", value: 3, type: "danger" }
  ];
  return getValue(list, val);
};

// 盘点结果 - 工具
export const stockTakeResult = val => {
  const list = [
    { name: "正常", value: 1, type: "success" },
    { name: "盘亏", value: 2, type: "danger" },
    { name: "盘赢", value: 3, type: "primary" }
  ];
  return getValue(list, val);
};

// 盘点结果 - 货架
export const stockTakeResultFacility = val => {
  const list = [
    { name: "正常", value: 1, type: "success" },
    { name: "异常", value: 2, type: "danger" }
  ];
  return `${val}` == "1" ? list[0] : list[1];
};
// 检查记录》检查结果
export const inspectState = val => {
  const list = [
    { name: "正常", value: 1, type: "success" },
    { name: "损坏", value: 2, type: "danger" }
  ];
  return getValue(list, val);
};
export default {
  // 库存状态
  storageState: val => {
    const list = [
      { name: "在库", type: "success", value: 1 },
      { name: "已退库", type: "info", value: 2 },
      { name: "待入库", type: "primary", value: 3 }
    ];
    return getValue(list, val);
  },
  stockTakeResult
};
